package com.java.util;

public class StringEncrypter {
	private static final int SHIFT_KEY = 5; // 加密解密的密钥

	/**
	 * 加密方法，将字符串每个字符向右移动SHIFT_KEY位
	 **/
	public static String encrypt(String text) {
		StringBuilder encryptedText = new StringBuilder();
		for (char c : text.toCharArray()) {
			encryptedText.append((char) (c + SHIFT_KEY));
		}
		return encryptedText.toString();
	}

	/**
	 * 解密方法，将字符串每个字符向左移动SHIFT_KEY位
	 **/
	public static String decrypt(String encryptedText) {
		StringBuilder text = new StringBuilder();
		for (char c : encryptedText.toCharArray()) {
			text.append((char) (c - SHIFT_KEY));
		}
		return text.toString();
	}

	public static void main(String[] args) {
		String originalText = "HelloWorld";
		String encryptedText = encrypt(originalText);
		System.out.println("Encrypted Text: " + encryptedText);

		String decryptedText = decrypt(encryptedText);
		System.out.println("Decrypted Text: " + decryptedText);
	}
}
